import java.io.*;
public class StudentText {
    public static void SerializationExample() {
        Postgraduate postgraduate = new Postgraduate("SerializationExample", 25, "Computer Science");

        try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("student.ser"))) {
            oos.writeObject(postgraduate);
            System.out.println("Object has been serialized");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void Deserialization() {
        try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream("student.ser"))) {
            Postgraduate postgraduate = (Postgraduate) ois.readObject();
            System.out.println("Object has been deserialized");
            System.out.println(postgraduate);
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
